let s = '([{}])'

var isValid = function(s) {
   const LtoR = {
        '(': ')',
        '[': ']',
        '{': '}'
    }
    const stack = []

    for(let i=0; i<s.length; i++)  {
        if (s[i] === '(' || s[i] ==='[' || s[i] === '{' ) {
            stack.push(s[i])
        }else{
            if (!stack.length || LtoR[stack.pop()] !== s[i] ) {
                return false
            }
        }
    }
    // if(stack.length){
    //     return false
    // }

    // return true
    return !stack.length
};

console.log(isValid(s));
